package com.example.batchprocessing.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

public class StringUtils {
  public static String randomString(int length){
    String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    Random random=new Random();
    StringBuffer sb=new StringBuffer();
    for(int i=0;i<length;i++){
      int number=random.nextInt(62);
      sb.append(str.charAt(number));
    }
    return sb.toString();
  }

  public static void main(String[] args) {
    try(FileOutputStream out = new FileOutputStream(
        new File("/workspace/gs-batch-processing/complete/src/main/resources/sample-data.csv"))){
      for(int i = 0; i < 100000; i++){
        out.write(String.format("%s,%s\n", i, randomString(10)).getBytes());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
